package net.ibizsys.eclipse.studio.handler;

import net.ibizsys.eclipse.studio.Activator;
import net.ibizsys.eclipse.studio.dialog.LoginViewDialog;
import net.ibizsys.eclipse.studio.dialog.MainViewDialog;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;

/**
 * 主窗口处理对象
 * 
 * @author <a href='http://www.weibo.com/xjtoo' target='_blank'>Enmaai</a>
 */
public class MainWindowHandler extends AbstractHandler
{
	public MainWindowHandler()
	{
	}

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException
	{
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

		if (Activator.getDefault().hasLogin())
		{
			new MainViewDialog(window.getShell()).open();
		} else
		{
			new LoginViewDialog(window.getShell()).open();
		}
		return null;
	}
}
